﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using AnimaGestionPersonnage.Utilities;

namespace AnimaGestionPersonnage.Vue
{
    public partial class FormSkillModder : Form
    {
        private int currentStatus = Utils.ERROR;

        public FormSkillModder()
        {
            InitializeComponent();
        }

        public void ShowDialog(IWin32Window owner, int status)
        {
            currentStatus = status;

            listBoxSkills.Items.Clear();

            switch (currentStatus)
            {
                case Utils.INNATE_BONUS:
                    labelBonus.Text = "Choisir le bonus désiré";
                    numericUpDownBonus.Increment = 5;
                    numericUpDownBonus.Minimum = 5;
                    numericUpDownBonus.Value = 5;
                    
                    foreach (BasicSkill s in Utils.primarySkillsList)
                    {
                        listBoxSkills.Items.Add(s.name);
                    }
                    foreach (BasicSkill s in Utils.secondarySkillsList)
                    {
                        listBoxSkills.Items.Add(s.name);
                    }
                    foreach (BasicSkill s in Utils.basicSkillsList)
                    {
                        listBoxSkills.Items.Add(s.name);
                    }
                    break;
                case Utils.REDUCED_COST:
                    labelBonus.Text = "Choisir le nouveau coût désiré";
                    numericUpDownBonus.Increment = 1;
                    numericUpDownBonus.Minimum = 1;
                    numericUpDownBonus.Value = 1;
                    
                    foreach (BasicSkill s in Utils.secondarySkillsList)
                    {
                        listBoxSkills.Items.Add(s.name);
                    }
                    break;
                case Utils.RACE_BONUS:
                    labelBonus.Text = "Choisir le bonus racial désiré";
                    numericUpDownBonus.Increment = 5;
                    numericUpDownBonus.Minimum = 5;
                    numericUpDownBonus.Value = 5;
                    
                    foreach (BasicSkill s in Utils.primarySkillsList)
                    {
                        listBoxSkills.Items.Add(s.name);
                    }
                    foreach (BasicSkill s in Utils.secondarySkillsList)
                    {
                        listBoxSkills.Items.Add(s.name);
                    }
                    foreach (BasicSkill s in Utils.basicSkillsList)
                    {
                        listBoxSkills.Items.Add(s.name);
                    }
                    break;
                default:
                    MessageBox.Show(this, "État de fenêtre non reconnu.", "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    break; 
            }
            base.ShowDialog(owner);
        }

        private void buttonAdd_Click(object sender, EventArgs e)
        {
            switch (currentStatus)
            {
                case Utils.INNATE_BONUS:
                    ((FormCreateCharClass)this.Owner).addInnateBonus(listBoxSkills.SelectedItem.ToString(), (int)numericUpDownBonus.Value);
                    break;
                case Utils.REDUCED_COST:
                    ((FormCreateCharClass)this.Owner).addReducedCost(listBoxSkills.SelectedItem.ToString(), (int)numericUpDownBonus.Value);
                    break;
                case Utils.RACE_BONUS:
                    ((ISkillBonusAdder)this.Owner).addSkillBonus(new SkillMod(listBoxSkills.SelectedItem.ToString(), (int)numericUpDownBonus.Value));
                    break;
                default:
                    MessageBox.Show(this, "État de fenêtre non reconnu.", "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    break;
            }
            this.Close();
        }

        private void buttonQuit_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
